import Vue from 'vue'
import login from '@/components/login'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
import list01 from '@/components/list01'
import dell from '@/components/dell'
import page from '@/components/page'
import list02 from '@/components/list02'
import detial from '@/components/detial'
import Regist from '@/components/Regist'
import rester from '@/components/rester'
import Code from '@/components/Code'
import Fen from '@/components/Fen'
import ToDoList from '@/components/ToDoList'
import miuse from '@/components/miuse'
import nativ from '@/components/nativ'
import sarch from '@/components/sarch'
import My from '@/components/My'
 //import { DelegatedPlugin } from 'webpack'
Vue.use(Router)


var router = new Router({
  routes: [
    {
      // path: 'helloworld',
      // name: 'HelloWorld',
      // component: HelloWorld
      path: '/list01',
      name: 'list01',
      component: list01
    },
    {
      path: '/dell',
      name: 'dell',
      component: dell
     
    },
    {
      path:'/login',
      name:'login',
      component: login
    },
    {
      path:'/page',
      name:'page',
      component: page
    },
    {
      path:'/',
      name:'list02',
      component:list02,
    },
    {
      path: '/detial',
      name: 'detial',
      component: detial
     
    },
    {
      path: '/regist',
      name: 'Regist',
      component: Regist
     
    },
    {
      path: '/rester',
      name: 'rester',
      component: rester
     
    },
    {
      path: '/bycode',
      name: 'Code',
      component: Code
     
    },
    {
      path: '/my',
      name: 'My',
      component: My
     
    },
    {
      path: '/todo',
      name: 'ToDoList',
      component: ()=>import("@/components/ToDoList")
     
    },
    {
      path: '/miuse',
      name: 'miuse',
      component: ()=>import("@/components/miuse")
     
    },
    {
      path: '/fen',
      name: 'Fen',
      component: ()=>import("@/components/Fen"),
      children:[
        {
          path:'/nativ/:id',
          name:'nativ',
          comments:()=>import("@/components/nativ"),
        }
      ]
     
    },
    {
      path: '/sarch',
      name: 'sarch',
      component: ()=>import("@/components/sarch")
     
    },
    
   
  ]
});
router.beforeEach((to,form,next)=>{
  if(to.path=="/rester" || to.path=="/regist" || to.path=="/bycode"){
    next();
  }else{
  if(sessionStorage.getItem("token")){
    next();
  }else{
    next("/rester");
  }
}
})

export default router;
